home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / CIncludes / MIDI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-29  |  9.4 KB  |  276 lines  |  [TEXT/MPS ]

  1.  
  2. /************************************************************
  3.  
  4. Created: Friday, September 13, 1991 at 12:57 PM
  5.  MIDI.h
  6.  C Interface to the Macintosh Libraries
  7.  
  8.  
  9.   Copyright Apple Computer, Inc. 1988-1991
  10.   All rights reserved
  11.  
  12. ************************************************************/
  13.  
  14.  
  15. #ifndef __MIDI__
  16. #define __MIDI__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22.  
  23. enum {
  24.  
  25.  
  26. #define midiToolNum 4                /*tool number of MIDI Manager for SndDispVersion call*/
  27.  
  28.  midiMaxNameLen = 31,                /*maximum number of characters in port and client names*/
  29.  
  30. /* Time formats */
  31.  midiFormatMSec = 0,                /*milliseconds*/
  32.  midiFormatBeats = 1,                /*beats*/
  33.  midiFormat24fpsBit = 2,            /*24 frames/sec.*/
  34.  midiFormat25fpsBit = 3,            /*25 frames/sec.*/
  35.  midiFormat30fpsDBit = 4,            /*30 frames/sec. drop-frame*/
  36.  midiFormat30fpsBit = 5,            /*30 frames/sec.*/
  37.  midiFormat24fpsQF = 6,                /*24 frames/sec. longInt format */
  38.  midiFormat25fpsQF = 7,                /*25 frames/sec. longInt format */
  39.  midiFormat30fpsDQF = 8,            /*30 frames/sec. drop-frame longInt format */
  40.  midiFormat30fpsQF = 9,                /*30 frames/sec. longInt format */
  41.  midiInternalSync = 0,                /*internal sync*/
  42.  midiExternalSync = 1,                /*external sync*/
  43.  
  44. /* Port types*/
  45.  midiPortTypeTime = 0,                /*time port*/
  46.  midiPortTypeInput = 1,                /*input port*/
  47.  midiPortTypeOutput = 2,            /*output port*/
  48.  midiPortTypeTimeInv = 3,            /*invisible time port*/
  49.  
  50. /* OffsetTimes  */
  51.  midiGetEverything = 0x7FFFFFFF,    /*get all packets, regardless of time stamps*/
  52.  midiGetNothing = 0x80000000,        /*get no packets, regardless of time stamps*/
  53.  midiGetCurrent = 0x00000000        /*get current packets only*/
  54. };
  55. enum {
  56.  
  57. /*    MIDI data and messages are passed in MIDIPacket records (see below).
  58.     The first byte of every MIDIPacket contains a set of flags
  59.    
  60.     bits 0-1    00 = new MIDIPacket, not continued
  61.                      01 = begining of continued MIDIPacket
  62.                      10 = end of continued MIDIPacket
  63.                     11 = continuation
  64.     bits 2-3     reserved
  65.   
  66.     bits 4-6      000 = packet contains MIDI data
  67.    
  68.                      001 = packet contains MIDI Manager message
  69.    
  70.     bit 7              0 = MIDIPacket has valid stamp
  71.                         1 = stamp with current clock */
  72.  midiContMask = 0x03,
  73.  midiNoCont = 0x00,
  74.  midiStartCont = 0x01,
  75.  midiMidCont = 0x03,
  76.  midiEndCont = 0x02,
  77.  midiTypeMask = 0x70,
  78.  midiMsgType = 0x00,
  79.  midiMgrType = 0x10,
  80.  midiTimeStampMask = 0x80,
  81.  midiTimeStampCurrent = 0x80,
  82.  midiTimeStampValid = 0x00,
  83.  
  84. /*    MIDI Manager MIDIPacket command words (the first word in the data field
  85.     for midiMgrType messages) */
  86.  midiOverflowErr = 0x0001,
  87.  midiSCCErr = 0x0002,
  88.  midiPacketErr = 0x0003,
  89.  midiMaxErr = 0x00FF,                /*all command words less than this value  are error indicators*/
  90.  
  91. /* Valid results to be returned by readHooks */
  92.  midiKeepPacket = 0,
  93.  midiMorePacket = 1,
  94.  midiNoMorePacket = 2,
  95.  
  96. /* Errors: */
  97.  midiNoClientErr = -250,            /*no client with that ID found*/
  98.  midiNoPortErr = -251                /*no port with that ID found*/
  99. };
  100. enum {
  101.  midiTooManyPortsErr = -252,        /*too many ports already installed in the system*/
  102.  midiTooManyConsErr = -253,            /*too many connections made*/
  103.  midiVConnectErr = -254,            /*pending virtual connection created*/
  104.  midiVConnectMade = -255,            /*pending virtual connection resolved*/
  105.  midiVConnectRmvd = -256,            /*pending virtual connection removed*/
  106.  midiNoConErr = -257,                /*no connection exists between specified ports*/
  107.  midiWriteErr = -258,                /*MIDIWritePacket couldn't write to all connected ports*/
  108.  midiNameLenErr = -259,                /*name supplied is longer than 31 characters*/
  109.  midiDupIDErr = -260,                /*duplicate client ID*/
  110.  midiInvalidCmdErr = -261,            /*command not supported for port type*/
  111.  
  112. /*     Driver calls: */
  113.  midiOpenDriver = 1,
  114.  midiCloseDriver = 2
  115. };
  116.  
  117. struct MIDIPacket {
  118.  unsigned char flags;
  119.  unsigned char len;
  120.  long tStamp;
  121.  unsigned char data[249];
  122. };
  123.  
  124. typedef struct MIDIPacket MIDIPacket;
  125. typedef MIDIPacket *MIDIPacketPtr;
  126.  
  127. struct MIDIClkInfo {
  128.  short sync;                        /*synchronization external/internal*/
  129.  long curTime;                        /*current value of port's clock*/
  130.  short format;                        /*time code format*/
  131. };
  132.  
  133. typedef struct MIDIClkInfo MIDIClkInfo;
  134.  
  135. struct MIDIIDRec {
  136.  OSType clientID;
  137.  OSType portID;
  138. };
  139.  
  140. typedef struct MIDIIDRec MIDIIDRec;
  141.  
  142. struct MIDIPortInfo {
  143.  short portType;                    /*type of port*/
  144.  MIDIIDRec timeBase;                /*MIDIIDRec for time base*/
  145.  short numConnects;                    /*number of connections*/
  146.  MIDIIDRec cList[1];                /*ARRAY [1..numConnects] of MIDIIDRec*/
  147. };
  148.  
  149. typedef struct MIDIPortInfo MIDIPortInfo;
  150. typedef MIDIPortInfo *MIDIPortInfoPtr, **MIDIPortInfoHdl;
  151.  
  152. struct MIDIPortParams {
  153.  OSType portID;                        /*ID of port, unique within client*/
  154.  short portType;                    /*Type of port - input, output, time, etc.*/
  155.  short timeBase;                    /*refnum of time base, 0 if none*/
  156.  long offsetTime;                    /*offset for current time stamps*/
  157.  Ptr readHook;                        /*routine to call when input data is valid*/
  158.  long refCon;                        /*refcon for port (for client use)*/
  159.  MIDIClkInfo initClock;                /*initial settings for a time base*/
  160.  Str255 name;                        /*name of the port, This is a real live string, not a ptr.*/
  161. };
  162.  
  163. typedef struct MIDIPortParams MIDIPortParams;
  164. typedef MIDIPortParams *MIDIPortParamsPtr;
  165.  
  166. struct MIDIIDList {
  167.  short numIDs;
  168.  OSType list[1];
  169. };
  170.  
  171. typedef struct MIDIIDList MIDIIDList;
  172. typedef MIDIIDList *MIDIIDListPtr, **MIDIIDListHdl;
  173.  
  174.  
  175. #ifdef __cplusplus
  176. extern "C" {
  177. #endif
  178. /* 
  179.     
  180.          Prototype Declarations for readHook and timeProc
  181.         
  182.          extern pascal short myReadHook(MIDIPacketPtr myPacket, long myRefCon);
  183.          extern pascal void myTimeProc(long curTime, long myRefCon);
  184.         
  185.          MIDI Manager Routines
  186. */
  187.  
  188. pascal long SndDispVersion(short toolnum); 
  189. pascal OSErr MIDISignIn(OSType clientID,long refCon,Handle icon,ConstStr255Param name)
  190.  = {0x203C,0x0004,midiToolNum,0xA800}; 
  191. pascal void MIDISignOut(OSType clientID)
  192.  = {0x203C,0x0008,midiToolNum,0xA800}; 
  193. pascal MIDIIDListHdl MIDIGetClients(void)
  194.  = {0x203C,0x000C,midiToolNum,0xA800}; 
  195. pascal void MIDIGetClientName(OSType clientID,Str255 name)
  196.  = {0x203C,0x0010,midiToolNum,0xA800}; 
  197. pascal void MIDISetClientName(OSType clientID,ConstStr255Param name)
  198.  = {0x203C,0x0014,midiToolNum,0xA800}; 
  199. pascal MIDIIDListHdl MIDIGetPorts(OSType clientID)
  200.  = {0x203C,0x0018,midiToolNum,0xA800}; 
  201. pascal OSErr MIDIAddPort(OSType clientID,short BufSize,short *refnum,MIDIPortParamsPtr init)
  202.  = {0x203C,0x001C,midiToolNum,0xA800}; 
  203. pascal MIDIPortInfoHdl MIDIGetPortInfo(OSType clientID,OSType portID)
  204.  = {0x203C,0x0020,midiToolNum,0xA800}; 
  205. pascal OSErr MIDIConnectData(OSType srcClID,OSType srcPortID,OSType dstClID,
  206.  OSType dstPortID)
  207.  = {0x203C,0x0024,midiToolNum,0xA800}; 
  208. pascal OSErr MIDIUnConnectData(OSType srcClID,OSType srcPortID,OSType dstClID,
  209.  OSType dstPortID)
  210.  = {0x203C,0x0028,midiToolNum,0xA800}; 
  211. pascal OSErr MIDIConnectTime(OSType srcClID,OSType srcPortID,OSType dstClID,
  212.  OSType dstPortID)
  213.  = {0x203C,0x002C,midiToolNum,0xA800}; 
  214. pascal OSErr MIDIUnConnectTime(OSType srcClID,OSType srcPortID,OSType dstClID,
  215.  OSType dstPortID)
  216.  = {0x203C,0x0030,midiToolNum,0xA800}; 
  217. pascal void MIDIFlush(short refnum)
  218.  = {0x203C,0x0034,midiToolNum,0xA800}; 
  219. pascal ProcPtr MIDIGetReadHook(short refnum)
  220.  = {0x203C,0x0038,midiToolNum,0xA800}; 
  221. pascal void MIDISetReadHook(short refnum,ProcPtr hook)
  222.  = {0x203C,0x003C,midiToolNum,0xA800}; 
  223. pascal void MIDIGetPortName(OSType clientID,OSType portID,Str255 name)
  224.  = {0x203C,0x0040,midiToolNum,0xA800}; 
  225. pascal void MIDISetPortName(OSType clientID,OSType portID,ConstStr255Param name)
  226.  = {0x203C,0x0044,midiToolNum,0xA800}; 
  227. pascal void MIDIWakeUp(short refnum,long time,long period,ProcPtr timeProc)
  228.  = {0x203C,0x0048,midiToolNum,0xA800}; 
  229. pascal void MIDIRemovePort(short refnum)
  230.  = {0x203C,0x004C,midiToolNum,0xA800}; 
  231. pascal short MIDIGetSync(short refnum)
  232.  = {0x203C,0x0050,midiToolNum,0xA800}; 
  233. pascal void MIDISetSync(short refnum,short sync)
  234.  = {0x203C,0x0054,midiToolNum,0xA800}; 
  235. pascal long MIDIGetCurTime(short refnum)
  236.  = {0x203C,0x0058,midiToolNum,0xA800}; 
  237. pascal void MIDISetCurTime(short refnum,long time)
  238.  = {0x203C,0x005C,midiToolNum,0xA800}; 
  239. pascal void MIDIStartTime(short refnum)
  240.  = {0x203C,0x0060,midiToolNum,0xA800}; 
  241. pascal void MIDIStopTime(short refnum)
  242.  = {0x203C,0x0064,midiToolNum,0xA800}; 
  243. pascal void MIDIPoll(short refnum,long offsetTime)
  244.  = {0x203C,0x0068,midiToolNum,0xA800}; 
  245. pascal OSErr MIDIWritePacket(short refnum,MIDIPacketPtr packet)
  246.  = {0x203C,0x006C,midiToolNum,0xA800}; 
  247. pascal Boolean MIDIWorldChanged(OSType clientID)
  248.  = {0x203C,0x0070,midiToolNum,0xA800}; 
  249. pascal long MIDIGetOffsetTime(short refnum)
  250.  = {0x203C,0x0074,midiToolNum,0xA800}; 
  251. pascal void MIDISetOffsetTime(short refnum,long offsetTime)
  252.  = {0x203C,0x0078,midiToolNum,0xA800}; 
  253. pascal long MIDIConvertTime(short srcFormat,short dstFormat,long time)
  254.  = {0x203C,0x007C,midiToolNum,0xA800}; 
  255. pascal long MIDIGetRefCon(short refnum)
  256.  = {0x203C,0x0080,midiToolNum,0xA800}; 
  257. pascal void MIDISetRefCon(short refnum,long refCon)
  258.  = {0x203C,0x0084,midiToolNum,0xA800}; 
  259. pascal long MIDIGetClRefCon(OSType clientID)
  260.  = {0x203C,0x0088,midiToolNum,0xA800}; 
  261. pascal void MIDISetClRefCon(OSType clientID,long refCon)
  262.  = {0x203C,0x008C,midiToolNum,0xA800}; 
  263. pascal short MIDIGetTCFormat(short refnum)
  264.  = {0x203C,0x0090,midiToolNum,0xA800}; 
  265. pascal void MIDISetTCFormat(short refnum,short format)
  266.  = {0x203C,0x0094,midiToolNum,0xA800}; 
  267. pascal void MIDISetRunRate(short refnum,short rate,long time)
  268.  = {0x203C,0x0098,midiToolNum,0xA800}; 
  269. pascal Handle MIDIGetClientIcon(OSType clientID)
  270.  = {0x203C,0x009C,midiToolNum,0xA800}; 
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274.  
  275. #endif
  276.